package com.vf.admin.common.filehandle;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.*;
import java.util.stream.Collectors;

/**
 * <p>Title : 铭感词.json文件读取</p>
 * <p>Description : </p>
 * <p>DevelopTools : IDEA</p>
 * <p>DevelopSystem : Windows10</p>
 *
 * @Author : NemoMeng
 * @Date 2023/7/4 14:41
 */
public class YSensitiveUtil {


    private static final String jsonFileUrl = "http://zhiyuapp.oss-cn-fuzhou.aliyuncs.com/sensitive/data.json";


    public static String readJsonFile() {

        StringBuilder sb = new StringBuilder();

        try {
            URL url = new URL(jsonFileUrl);
            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
            String jsonLine;
            while ((jsonLine = in.readLine()) != null) {
                sb.append(jsonLine);
            }
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return sb.toString();

    }

    public static void main(String[] args) {
        String textJson = readJsonFile();
        JSONObject jsonObject = JSON.parseObject(textJson);
        JSONArray jsonArray = jsonObject.getJSONArray("content");
        System.out.println(jsonArray);

//       String text = "嘎嘎大噶大哥肏死打算低矮";
//
//        jsonArray.forEach(e->{
//           if (text.indexOf(e.toString()) > -1){
//               System.out.println("匹配");
//           }
//
//
//
//        });
    }


}



